﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Layout/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyClub.Web.Default" %>
<%@ Register TagPrefix="myclub" Namespace="MyClub.Web.UI.WebControls" Assembly="MyClub.Web" %>

<asp:Content ID="Column1Content" ContentPlaceHolderID="Column1ContentPlaceHolder" runat="server">
    <asp:LinqDataSource ID="PostData" runat="server"
        ContextTypeName="MyClub.Model.MyClubEntities"
        TableName="Post"
        Where="Path.StartsWith(@categoryPath)"
        OrderBy="CreationDate descending"
        >
        <WhereParameters>
            <asp:Parameter Name="categoryPath" Type="String" Size="1024" DefaultValue="/" />   
        </WhereParameters>
    </asp:LinqDataSource>
    <asp:ListView ID="PostView" runat="server" DataSourceID="PostData" DataKeyNames="Id" ItemPlaceholderID="Posts">
        <LayoutTemplate>
            <div class="postList">
                <asp:PlaceHolder ID="Posts" runat="server" />
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <myclub:SwitchView ID="SwitchView1" runat="server" Descriminator='<%# Container.DataItem.GetType().Name %>'>
                <Cases>
                    <myclub:SwitchViewCase Value="ArticlePost" CaseTemplateFile="~/Templates/ArticlePostSummary.ascx" />
                </Cases>
                <DefaultTemplate>
                    <div class="post">
                        <h1 class="title"><%# Eval("Title") %></h1>
                        <p class="summary"><%# Eval("Summary") %></p>
                    </div>
                </DefaultTemplate>
            </myclub:SwitchView>
        </ItemTemplate>
        <ItemSeparatorTemplate>
            <div class="seperator"></div>
        </ItemSeparatorTemplate>
        <EmptyDataTemplate>
            <div class="postList">
                <div class="post">
                    <h1 class="title">Empty category</h1>
                    <p class="summary">There are currently no posts in this category.</p>
                </div>
            </div>
        </EmptyDataTemplate>
    </asp:ListView>
</asp:Content>